#include <stdio.h>
#include <iostream>
#include <cstring>
#include"../base.h"
using namespace std;
int findMinNotExist(int A[],int n){
	int* B = (int*)malloc(sizeof(int) * n);
	memset(B, 0, sizeof(int) * n);
	for (int i = 0; i < n; i++)
	{
		int j = abs(A[i]);
		if (j >n){continue;}
		if (B[j]==0)
		{
			B[j] = 1;
		}
	}
	printArr(B, n);
	for (int i = 1; i < n; i++)
	{
		if (B[i] == 0) {
		free(B);
		return i;
		};

	}
}

int main() {
	int A[] = { 3,10,5,2,7,8,1 };
	cout<<findMinNotExist(A, 7);
	return -1;
}